import matplotlib.pyplot as plt
import numpy as np


def show_graph(path, x_list, y_train_list, y_val_list, exp_name, title, x_label, y_label, legend=[]):
    plt.figure()
    plt.plot(x_list, y_train_list)
    plt.plot(x_list, y_val_list)
    plt.title(title)
    plt.xlabel(x_label)
    plt.ylabel(y_label)
    plt.legend(legend)
    plt.savefig(f"{path}/{exp_name}-{title}.png")


def save_data(path, trian_loss, val_loss, train_miou, val_miou, exp_name):
    file = open(f"{path}/{exp_name}.txt", 'w')
    for line_data in zip(trian_loss, val_loss, train_miou, val_miou):
        line_data = list(line_data)
        line = ' '.join([str(t) for t in line_data])
        file.write(line)
        file.write('\n')
    file.close()

#
# train_loss=[0.2,0.3]
# val_loss=[1,2]
# train_miou=[4,5]
# val_miou=[8,9]
# exp_name="unet"
# save_data(train_loss, val_loss, train_miou, val_miou, exp_name)
